<?php

class DomObj extends DataHolder implements IDomObj
{

  /**
   *
   * @var string
   */
  protected $name;

  /**
   *
   * @var boolean
   */
  protected $new = true;

  /**
   *
   * @var IDomObjDefinition
   */
  protected $definition;

  /**
   *
   * @var string
   */
  protected $uid;

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/data/DataHolder#commit()
   */
  public function commit()
  {
    $this->new = false;
    return parent::commit();
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/api/IDomObj#getDefinition()
   */
  public function getDefinition()
  {
    if (empty($this->definition)) {
      $this->definition = Domain::getInstance()->getObject(strtolower($this->getName()));
    }

    return $this->definition;
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/api/IDomObj#getName()
   */
  public function getName()
  {
    if (empty($this->name)) {
      $this->name = get_class($this);
    }

    return $this->name;
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/api/IDomObj#getUid()
   */
  public function getUid()
  {
    if (empty($this->uid)) {
      $this->uid = $this->getName() . '_' . uniqid();
    }

    return $this->uid;
  }

  /**
   * (non-PHPdoc)
   * @see simplify/kernel/domain/api/IDomObj#isNew()
   */
  public function isNew()
  {
    return $this->new;
  }

}

?>